package BeenChina.PM.Util;
import java.beans.XMLEncoder;
import java.beans.XMLDecoder;
import java.io.*;

public class xmlSerializer<T> {	
	public  void write(T f, String filename) throws Exception{
	    XMLEncoder encoder =
	       new XMLEncoder(
	          new BufferedOutputStream(
	            new FileOutputStream(filename)));
	    encoder.writeObject(f);
	    encoder.close();
	}
	
	public  T read(String filename) throws Exception {
	    XMLDecoder decoder =
	        new XMLDecoder(new BufferedInputStream(
	            new FileInputStream(filename)));
	    
		T o = (T)decoder.readObject();
	    decoder.close();
	    return o;
	}

}
